package com.pxx.pj.pxx.controller;

import com.pxx.pj.common.pojo.JsonResult;
import com.pxx.pj.pxx.pojo.PxxMenu;
import com.pxx.pj.pxx.service.PxxMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PxxMenuController {

    @Autowired
    private PxxMenuService pxxMenuService;

    @PostMapping("/menu/doSaveObject")
    public JsonResult doSaveObject(PxxMenu entity){
        pxxMenuService.saveObject(entity);
        return new JsonResult("save ok");
    }

    @PostMapping("/menu/doUpdateObject")
    public JsonResult doUpdateObject(PxxMenu entity){
        pxxMenuService.updateObject(entity);
        return new JsonResult("update ok");
    }

    @GetMapping("/menu/doFindZtreeMenuNodes")
    public JsonResult doFindZtreeMenuNodes(){
        return new JsonResult(pxxMenuService.findZtreeMenuNodes());
    }

    @RequestMapping("/menu/doDeleteObject")
    public JsonResult doDeleteObject(Integer id){
        pxxMenuService.deleteObject(id);
        return new JsonResult("delete ok");
    }

    @GetMapping("/menu/doFindObjects")
    public JsonResult doFindObjects(){
        return new JsonResult(pxxMenuService.findObjects());
    }
}
